Processing math: 100%

ode_integrator Derived Type

type, public :: ode_integrator

The most basic ODE integrator object capable of integrating systems of ODE's.


Type-Bound Procedures

procedure, public :: append_to_buffer => oi_append_to_buffer

Appends the supplied solution point to the internal solution buffer.

  • private subroutine oi_append_to_buffer(this, x, y, err)

    Appends the supplied solution point to the internal solution buffer.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: x

    The independent variable value.

    real(kind=real64), intent(in), dimension(:) :: y

    The values of the dependent variables corresponding to x.

    class(errors), intent(inout), optional, target :: err

    An optional errors-based object that if provided can be used to retrieve information relating to any errors encountered during execution. If not provided, a default implementation of the errors class is used internally to provide error handling. Possible errors and warning messages that may be encountered are as follows.

    • DIFFEQ_MEMORY_ALLOCATION_ERROR: Occurs if there is a memory allocation issue.

procedure, public :: clear_buffer => oi_clear_buffer

Clears the contents of the buffer.

  • private subroutine oi_clear_buffer(this)

    Clears the contents of the buffer.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

procedure, public :: compute_error_norm => oi_estimate_error

Computes the norm of the scaled error estimate.

  • private pure function oi_estimate_error(this, y, yest, yerr) result(rst)

    Computes the norm of the scaled error estimate. A value less than one indicates a successful step. A value greater than one suggests that the results do not meet the requested tolerances.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    real(kind=real64), intent(in), dimension(:) :: y

    The previously accepted solution array (N-element).

    real(kind=real64), intent(in), dimension(size(y)) :: yest

    An N-element array containing the next solution point estimate.

    real(kind=real64), intent(in), dimension(size(y)) :: yerr

    An N-element array containing the estimate of error for each equation.

    Return Value real(kind=real64)

    The norm of the scaled error.

procedure, public :: estimate_inital_step_size => oi_initial_step

Computes an estimate of an initial step size.

  • private pure subroutine oi_initial_step(this, sys, xo, xf, yo, fo, h)

    Computes an estimate of an initial step size.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    class(ode_container), intent(in) :: sys

    The ode_container object containing the ODE's to integrate.

    real(kind=real64), intent(in) :: xo

    The initial value of the independent variable.

    real(kind=real64), intent(in) :: xf

    The final value of the independent variable.

    real(kind=real64), intent(in), dimension(:) :: yo

    The initial values of the dependent variables (N-element).

    real(kind=real64), intent(out), dimension(size(yo)) :: fo

    An N-element array where the function values at xo will be written.

    real(kind=real64), intent(out) :: h

    The initial step size estimate.

procedure, public :: estimate_next_step_size => oi_next_step

Estimates the next step size.

  • private function oi_next_step(this, e, eold, h, x, err) result(rst)

    Estimates the next step size based upon the current and previous error estimates.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: e

    The norm of the current scaled error estimate.

    real(kind=real64), intent(inout) :: eold

    The norm of the previous step's scaled error estimate. On output, this variable is updated.

    real(kind=real64), intent(in) :: h

    The current step size.

    real(kind=real64), intent(in) :: x

    The current independent variable value.

    class(errors), intent(inout), optional, target :: err

    An optional errors-based object that if provided can be used to retrieve information relating to any errors encountered during execution. If not provided, a default implementation of the errors class is used internally to provide error handling. Possible errors and warning messages that may be encountered are as follows.

    • DIFFEQ_STEP_SIZE_TOO_SMALL_ERROR: Occurs if the step size becomes too small in magnitude.

    Return Value real(kind=real64)

    The new step size estimate.

procedure, public :: get_absolute_tolerance => oi_get_abs_tol

Gets the absolute error tolerance.

  • private pure function oi_get_abs_tol(this) result(rst)

    Gets the absolute error tolerance.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value real(kind=real64)

    The tolerance value.

procedure, public :: get_allow_overshoot => oi_get_allow_overshoot

Gets a value determining if the solver is allowed to overshoot the final value in the integration range.

  • private pure function oi_get_allow_overshoot(this) result(rst)

    Gets a value determining if the solver is allowed to overshoot the final value in the integration range.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value logical

    True if the solver can overshoot, and then interpolate to achieve the required final value; else, false thereby indicating the solver cannot overshoot.

procedure, public :: get_maximum_step_size => oi_get_max_step

Gets the magnitude of the maximum allowed step size.

  • private pure function oi_get_max_step(this) result(rst)

    Gets the magnitude of the maximum allowed step size.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value real(kind=real64)

    The step size limit.

procedure, public :: get_minimum_step_size => oi_get_min_step

Gets the magnitude of the minimum allowed step size.

  • private pure function oi_get_min_step(this) result(rst)

    Gets the magnitude of the minimum allowed step size.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value real(kind=real64)

    The step size limit.

procedure(ode_integer_inquiry), public, deferred, pass :: get_order

Returns the order of the integrator.

  • pure function ode_integer_inquiry(this) result(rst) Prototype

    Returns an integer value from the ode_integrator object.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value integer(kind=int32)

    The requested value.

procedure, public :: get_relative_tolerance => oi_get_abs_tol

Gets the relative error tolerance.

  • private pure function oi_get_abs_tol(this) result(rst)

    Gets the absolute error tolerance.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value real(kind=real64)

    The tolerance value.

procedure, public :: get_solution => oi_get_solution

Returns the solution computed by the integrator.

  • private pure function oi_get_solution(this) result(rst)

    Returns the solution computed by the integrator stored as a matrix with the first column containing the values of the independent variable at which the solution was computed. The remaining columns contain the solutions for each of the integrated equations in the order in which they appear in the source routine. Notice, the solve routine must be called before this routine.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value real(kind=real64), allocatable, dimension(:,:)

    The resulting solution matrix.

procedure, public :: get_step_limit => oi_get_step_limit

Gets the limit on the number of integration steps.

  • private pure function oi_get_step_limit(this) result(rst)

    Gets the limit on the number of integration steps that may be taken before the solver terminates.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value integer(kind=int32)

    The step limit.

procedure, public :: get_step_size_control_parameter => oi_get_control_parameter

Gets the step size PI control parameter.

  • private pure function oi_get_control_parameter(this) result(rst)

    Gets the step size control parameter β used for PI control of the step size. A value of 0 provides a default step size controller (non-PI); however, a nonzero value of β provides PI control that improves stability, but comes with a potential for efficiency loss. A good estimate for a starting point for this parameter is β=0.4k where k is the order of the integrator.

    The PI controller for step size is defined as follows. hn+1=fshneαneβn1

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value real(kind=real64)

    The control parameter.

procedure, public :: get_step_size_factor => oi_get_safety_factor

Gets the step size safety factor.

  • private pure function oi_get_safety_factor(this) result(rst)

    Gets the safety factor (step size multiplier) used to provide a measure of control to the step size estimate such that hnew=fsh, where fs is this safety factor.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(in) :: this

    The ode_integrator object.

    Return Value real(kind=real64)

    The safety factor.

procedure, public :: set_absolute_tolerance => oi_set_abs_tol

Sets the absolute error tolerance.

  • private subroutine oi_set_abs_tol(this, x)

    Sets the absolute error tolerance.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: x

    The tolerance value.

procedure, public :: set_allow_overshoot => oi_set_allow_overshoot

Sets a value determining if the solver is allowed to overshoot the final value in the integration range.

  • private subroutine oi_set_allow_overshoot(this, x)

    Sets a value determining if the solver is allowed to overshoot the final value in the integration range.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    logical, intent(in) :: x

    True if the solver can overshoot, and then interpolate to achieve the required final value; else, false thereby indicating the solver cannot overshoot.

procedure, public :: set_maximum_step_size => oi_set_max_step

Sets the magnitude of the maximum allowed step size.

  • private subroutine oi_set_max_step(this, x)

    Sets the magnitude of the maximum allowed step size.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: x

    The step size limit.

procedure, public :: set_minimum_step_size => oi_set_min_step

Sets the magnitude of the minimum allowed step size.

  • private subroutine oi_set_min_step(this, x)

    Sets the magnitude of the minimum allowed step size.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: x

    The step size limit.

procedure, public :: set_relative_tolerance => oi_set_abs_tol

Sets the relative error tolerance.

  • private subroutine oi_set_abs_tol(this, x)

    Sets the absolute error tolerance.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: x

    The tolerance value.

procedure, public :: set_step_limit => oi_set_step_limit

Sets the limit on the number of integration steps.

  • private subroutine oi_set_step_limit(this, x)

    Sets the limit on the number of integration steps that may be taken before the solver terminates.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    integer(kind=int32), intent(in) :: x

    The step limit.

procedure, public :: set_step_size_control_parameter => oi_set_control_parameter

Sets the step size PI control parameter.

  • private subroutine oi_set_control_parameter(this, x)

    Sets the step size control parameter β used for PI control of the step size. A value of 0 provides a default step size controller (non-PI); however, a nonzero value of β provides PI control that improves stability, but comes with a potential for efficiency loss. A good estimate for a starting point for this parameter is β=0.4k where k is the order of the integrator.

    The PI controller for step size is defined as follows. hn+1=fshneαneβn1

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: x

    The control parameter

procedure, public :: set_step_size_factor => oi_set_safety_factor

Sets the step size safety factor.

  • private subroutine oi_set_safety_factor(this, x)

    Sets the safety factor (step size multiplier) used to provide a measure of control to the step size estimate such that hnew=fsh, where fs is this safety factor.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    real(kind=real64), intent(in) :: x

    The safety factor.

procedure(ode_solver), public, deferred, pass :: solve

Solves the supplied system of ODE's.

  • subroutine ode_solver(this, sys, x, iv, err) Prototype

    Solves the supplied system of ODE's.

    Arguments

    Type IntentOptional Attributes Name
    class(ode_integrator), intent(inout) :: this

    The ode_integrator object.

    class(ode_container), intent(inout) :: sys

    The ode_container object containing the ODE's to integrate.

    real(kind=real64), intent(in), dimension(:) :: x

    An array, of at least 2 values, defining at a minimum the starting and ending values of the independent variable integration range. If more than two values are specified, the integration results will be returned at the supplied values.

    real(kind=real64), intent(in), dimension(:) :: iv

    An array containing the initial values for each ODE.

    class(errors), intent(inout), optional, target :: err

    An optional errors-based object that if provided can be used to retrieve information relating to any errors encountered during execution. If not provided, a default implementation of the errors class is used internally to provide error handling. Possible errors and warning messages that may be encountered are as follows.

    • DIFFEQ_MEMORY_ALLOCATION_ERROR: Occurs if there is a memory allocation issue.

    • DIFFEQ_NULL_POINTER_ERROR: Occurs if no ODE function is defined.

    • DIFFEQ_ARRAY_SIZE_ERROR: Occurs if there are less than 2 values given in the independent variable array x.